package com.yjc.dp;

/**
 * 45. 跳跃游戏 II
 *
 * @author yjc
 * @create 2024-08-09 9:16
 */
public class Subject_14 {
    public static void main(String[] args) {
        int[] nums = {2, 3, 1, 1, 4};
        int n = nums.length;

        int[] dp = new int[n];
        for (int i = 1; i < n; i++) {
            dp[i] = n + 1;
        }


        for (int i = 1; i < n; i++) {//找到每个点的最小步数
            for (int j = 0; j < i; j++) {//从头一直比较到 i 下标
                if (j + nums[j] >= i) {
                    dp[i] = Integer.min(dp[i], dp[j] + 1);
                }
            }
        }
        System.out.println(dp[n - 1]);


    }
}
